#ifndef MISC_INFO_H
#define MISC_INFO_H

#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <errno.h>
#include "securec.h"

//misc data size definition.
#define BOOT_SLOT_SIZE      1
#define RUNNING_SLOT_SIZE   1
#define COMMAND_SIZE        32
#define STATUS_SIZE         32
#define RESERVED_SIZE       958

// misc partition offset definition.
#define MISC_BASE_OFFSET	0
#define MISC_BOOT_SLOT_OFFSET	MISC_BASE_OFFSET
#define MISC_RUNNING_SLOT_OFFSET	(MISC_BASE_OFFSET + BOOT_SLOT_SIZE)
#define MISC_COMMAND_OFFSET	(MISC_BASE_OFFSET + BOOT_SLOT_SIZE + RUNNING_SLOT_SIZE)
#define MISC_STATUS_OFFSET	(MISC_BASE_OFFSET + BOOT_SLOT_SIZE + RUNNING_SLOT_SIZE + COMMAND_SIZE)

// misc offset
#define MISC_OFFSET 0L

typedef struct boot_message {
    char slot[BOOT_SLOT_SIZE];
    char running_slot[RUNNING_SLOT_SIZE];
    char command[COMMAND_SIZE];
    char status[STATUS_SIZE];
    char reserved[RESERVED_SIZE];
} boot_msg;

void print_misc_data(boot_msg* data);
int write_boot_msg(const char* dev, const boot_msg* boot);
int read_boot_msg(const char* dev, boot_msg* boot);
#endif /* MISC_INFO_H */
